﻿using MVC4.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MVC4.Controllers
{
    public class SelectController : Controller
    {
        //
        // GET: /Select/
        testEntities1 db = new testEntities1();
        public ActionResult Index()
        {
            return View();
        }
        public ActionResult Select()
        {
            //DbQuery
            List<Models.HKJR> list = (from dele in db.HKJRs select dele).ToList();
            ViewData["DataList"] = list;
            return View();
        }
        public ActionResult del(short id)
        {

            try
            {
                HKJR model = new HKJR() { ID = id };

                db.HKJRs.Attach(model);
                db.HKJRs.Remove(model);
                db.SaveChanges();
                return RedirectToAction("Select", "Select");
            }
            catch (Exception ex)
            {
                return Content("删除失败" + ex.Message);
            }

        }
    }
}
